package org.future.dataanalysis.bean;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Dongwei-Chen
 * @Date 2023/12/21 10:57
 * @Description
 */
@Data
public class DataUnit implements Serializable {

    public DataUnit() {
        this.dataArea = new HashMap<>();
    }

    public DataUnit(String topic) {
        this.topic = topic;
        this.dataArea = new HashMap<>();
    }

    private String topic;

    private String dataItemId;

    private String pkFields;

    private String groupId;

    private Map<String, Object> dataArea;

    private Map<String, Object> redisKey;

    public void searchRedis(String key, Object val) {
        if (redisKey == null) {
            redisKey = new HashMap<>();
        }
        redisKey.put(key, val);
    }

    public void put(String key, Object val) {
        dataArea.put(key, val);
    }

    public Object get(String key) {
        return this.dataArea.get(key);
    }

    public void putAll(DataUnit data) {
        dataArea.putAll(data.getDataArea());
    }
}
